/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AdminShowTimes.java
 *
 * Created on Apr 30, 2012, 7:02:18 PM
 */
package GUI.Admin;

import dao.SuatChieuDAO;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;
import java.util.Vector;
import javax.swing.ActionMap;
import javax.swing.JOptionPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import org.jdesktop.application.Action;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.Task;
import pojo.Suatchieu;
import utils.BusyIndicator;
import utils.BusyIndicatorInputBlocker;
import utils.ClassUtils;

/**
 *
 * @author Hnmtuan
 */
public class AdminShowTimes extends javax.swing.JPanel {

    // <editor-fold defaultstate="collapsed" desc="Define all variables using this application">
    private SingleFrameApplication localApplication;
    private BusyIndicator localBusy;
    private ActionMap _rsActionMap;
    private DefaultTableModel _showTimesModel;
    private List<Suatchieu> _showTimes;
    private boolean saveNeeded, cancelSelected, newRow;
    private String DEFAULT_SEARCH_STRING;
    // </editor-fold>
    //<editor-fold defaultstate="collapsed" desc="Define messages and error messages" >
    private final String MSG_EMPTY = "";
    private final String ERR_LIST_EMPTY = "Showtime list is empty";
    private final String MSG_LOADING = "Reloading list show times  .... !";
    private final String MSG_SAVE_SUCCESS = "Insert film successfully";
    private final String MSG_SAVE_BEGINNING = "Begin saving .... !";
    private final String MSG_SAVE_DATABASE = "Saving database  .... !";
    private final String MSG_UPDATE_SUCCESS = "Update film successfully";
    private final String MSG_UPDATE_BEGINNING = "Begin updating .... !";
    private final String MSG_UPDATE_DATABASE = "Updating database  .... !";
    private final String MSG_DELETE_SUCCESS = "Delete film type successfully";
    private final String MSG_DELETE_BEGINNING = "Begin deleteing .... !";
    private final String MSG_DELETE_DATABASE = "Deleteing database  .... !";
    private final String MSG_DELETE_CONFIRM = "Do you want to delete %s ?";
    private final String MSG_DELETE_TITLE = "Delete Film Type";
    private final String MSG_SEARCH_BEGINNING = "Begin searching .... !";
    private final String MSG_SEARCH_SUCCESS = "Search successfully .... !";
    private final String ERR_SAVE_TASK = "Save task not done !";
    private final String ERR_SELECT_OUTOFBOUND = "You select out of bound !";
    private final String ERR_SELECTED_TYPE_EMPTY = "Selected type is empty";
    private final String ERR_UPDATE_INVALID_PARAMS = "Update invalid parameters !";
    private final String ERR_UPDATE_TASK = "Update task not done !";
    private final String ERR_DELETE_INVALID_PARAMS = "Delete invalid parameters !";
    private final String ERR_DELETE_TASK = "Delete task not done !";
    private final String ERR_SEARCH_INVALID_PARAMS = "Search invalid parameters !";
    private final String ERR_SEARCH_INVALID_SOURCES = "Source search empty !";
    private final String ERR_SEARCH_NOT_FOUND = "%s not found !";
    private final String ERR_SEARCH_TASK = "Search task not done !";
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Define Constructor" >

    public AdminShowTimes(SingleFrameApplication appContext, BusyIndicator busy) throws Exception {
        localApplication = appContext;
        localBusy = busy;
        initComponents();
        initActions();
        loadShowTimes();
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Define Init Actions" >

    private void initActions() throws Exception {
         java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("GUI/Admin/resources/AdminShowTimes");
        _rsActionMap = Application.getInstance(main.MainFormApp.class).getContext().getActionMap(getClass(), this);
        jbtnSearch.setAction(_rsActionMap.get("searchFilms"));
        jbtnReset.setAction(_rsActionMap.get("resetRow"));
        jbtnAdd.setAction(_rsActionMap.get("addRow"));
        jbtnUpdate.setAction(_rsActionMap.get("updateRow"));
        jbtnDelete.setAction(_rsActionMap.get("deleteRow"));
        jbtnCancel.setAction(_rsActionMap.get("cancelRow"));
        setNewRow(true);
        DEFAULT_SEARCH_STRING = bundle.getString("jtfSearchShowTimes.title");
        jtbShowTimes.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            // -->>> not revoiked event throws exception

            public void valueChanged(ListSelectionEvent e) {
                if (isRecordSelected()) {
                    loadFields();
                }
                firePropertyChange("recordSelected", !isRecordSelected(), isRecordSelected());
                setSaveNeeded(true);
                setCancelSelected(true);
                setNewRow(false);
            }
        });
        jtfSearch.addMouseListener(new MouseAdapter() {

            // Compsite of two actions Press and Release
            @Override
            public void mouseClicked(MouseEvent e) {
                String searchText = jtfSearch.getText();
                // if text field empty so on ...
                if (searchText.equalsIgnoreCase(DEFAULT_SEARCH_STRING)) {
                    jtfSearch.setText("");
                }
            }

            @Override
            public void mouseExited(MouseEvent e) {
                String searchText = jtfSearch.getText();
                // if texfield empty so write default text for it
                if (searchText.equalsIgnoreCase("")) {
                    jtfSearch.setText(DEFAULT_SEARCH_STRING);
                }
                // else nothing else ..
            }
        });
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Implement All Actions">

    @Action
    public Task searchFilms() {
        Task task = new SearchTask();
        task.setInputBlocker(new BusyIndicatorInputBlocker(task, this.localBusy));
        return task;
    }

    @Action
    public void resetRow() {
        clearAllTextField();
    }

    @Action(enabledProperty = "newRow")
    public Task addRow() {
        Task task = new SaveTask();
        task.setInputBlocker(new BusyIndicatorInputBlocker(task, this.localBusy));
        return task;
    }

    @Action(enabledProperty = "saveNeeded")
    public Task updateRow() {
        Task task = new UpdateTask();
        task.setInputBlocker(new BusyIndicatorInputBlocker(task, this.localBusy));
        return task;
    }

    @Action(enabledProperty = "recordSelected")
    public Task deleteRow() {
        Task task = new DeleteTask();
        task.setInputBlocker(new BusyIndicatorInputBlocker(task, this.localBusy));
        return task;
    }

    @Action(enabledProperty = "cancelSelected")
    public void cancelRow() {
        defaultButtonState();
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Implement All Property or State">

    public boolean isNewRow() {
        return newRow;
    }

    public void setNewRow(boolean newRow) {
        if (newRow != this.newRow) {
            this.newRow = newRow;
            firePropertyChange("newRow", !this.newRow, this.newRow);
        }
    }

    public boolean isSaveNeeded() {
        return saveNeeded;
    }

    public void setSaveNeeded(boolean saveNeeded) {
        if (saveNeeded != this.saveNeeded) {
            this.saveNeeded = saveNeeded;
            firePropertyChange("saveNeeded", !this.saveNeeded, this.saveNeeded);
        }
    }

    public boolean isRecordSelected() {
        return jtbShowTimes.getSelectedRow() != -1;
    }

    public boolean isCancelSelected() {
        return cancelSelected;
    }

    public void setCancelSelected(boolean cancelSelected) {
        if (cancelSelected != this.cancelSelected) {
            this.cancelSelected = cancelSelected;
            firePropertyChange("cancelSelected", !this.cancelSelected, this.cancelSelected);
        }
    }

    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Implement Actions to GUI" >
    protected final void loadFields() {
        try {
            if (_showTimes == null) {
                throw new Exception(ERR_LIST_EMPTY);
            }
            int maxSize = _showTimes.size();
            int selectedRow = jtbShowTimes.getSelectedRow(); //row which you select into JTable
            if (selectedRow > maxSize) {
                throw new Exception(ERR_SELECT_OUTOFBOUND);
            }
            Suatchieu selectedShowTime = _showTimes.get(selectedRow);
            if (selectedShowTime == null) {
                throw new Exception(ERR_SELECTED_TYPE_EMPTY);
            }
            jtfCodeShowTime.setText(selectedShowTime.getCodeSuatChieu());
            jtfStartTimeShowTime.setText(selectedShowTime.getGioBatDau());
            jtfEndTimeShowTime.setText(selectedShowTime.getGioKetThuc());
        } catch (Exception e) {
            //System.out.println(String.format("Error: %s", e.getMessage()));
            e.printStackTrace(); //-->>> show remove this code
        }
    }

    protected final void clearAllTextField() {
        jtfCodeShowTime.setText(MSG_EMPTY);
        jtfStartTimeShowTime.setText(MSG_EMPTY);
        jtfEndTimeShowTime.setText(MSG_EMPTY);
    }

    protected final void defaultButtonState() {
        jtbShowTimes.clearSelection();
        firePropertyChange("recordSelected", isRecordSelected(), !isRecordSelected());
        setSaveNeeded(false);
        setCancelSelected(false);
        setNewRow(true);
    }

    protected final void loadShowTimes() throws Exception {
        _showTimesModel = (DefaultTableModel) jtbShowTimes.getModel();
        _showTimesModel.getDataVector().clear();
        try {
            _showTimes = SuatChieuDAO.getSuatChieus();
            if (_showTimes == null) {
                throw new Exception(ERR_LIST_EMPTY);
            }
            int count = 0;
            for (Suatchieu showTime : _showTimes) {
                Vector v = new Vector();
                count = count + 1;
                v.addElement(count);
                v.addElement(showTime.getCodeSuatChieu());
                v.addElement(showTime.getGioBatDau());
                v.addElement(showTime.getGioKetThuc());
                _showTimesModel.addRow(v);
            }
            jtbShowTimes.setModel(_showTimesModel);
        } catch (Exception ex) {
            throw new Exception(ex.getMessage());
        }
    }

    protected final int getShowTimeByCode(String code) throws Exception {
        if (code.isEmpty()) {
            throw new Exception(ERR_SEARCH_INVALID_PARAMS);
        }
        if (_showTimes == null || _showTimes.size() < 1) {
            throw new Exception(ERR_SEARCH_INVALID_SOURCES);
        }
        int searchIndex = -1;
        int maxSize = _showTimes.size();
        for (Suatchieu item : _showTimes) {
            searchIndex++;
            if (item.getCodeSuatChieu().equalsIgnoreCase(code)) {
                return searchIndex;
            }
        }
        return searchIndex = (searchIndex == maxSize - 1) ? -1 : searchIndex;
    }

    protected final void setSelectedRowShowTime(int index) {
        if (index == -1) {
            return;
        }
        jtbShowTimes.changeSelection(index, 0, false, false);
    }

    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Define Search Task" >
    private class SearchTask extends Task<Void, Void> {

        public SearchTask() {
            super(localApplication);
        }

        @Override
        protected Void doInBackground() throws Exception {
            setMessage(MSG_SEARCH_BEGINNING);
            Thread.sleep(150L);
            setProgress(1, 0, 3);
            // Check text field to input text not empty or default text
            String searchField = jtfSearch.getText();
            int resultIndex = -1;
            // Check option search to be checked
            resultIndex = getShowTimeByCode(searchField);
            // Get object is selected
            if (resultIndex == -1) {
                throw new Exception(String.format(ERR_SEARCH_NOT_FOUND, searchField));
            }
            // Search database
            setSelectedRowShowTime(resultIndex);
            // Loading GUI
            setMessage(MSG_LOADING);
            Thread.sleep(150L);
            setProgress(2, 0, 3);
            return null;
        }

        @Override
        protected void cancelled() {
            setMessage(ERR_SEARCH_TASK);
        }

        @Override
        protected void failed(Throwable thrwbl) {
            setMessage(thrwbl.getMessage());
            clearAllTextField();
            defaultButtonState();
        }

        @Override
        protected void succeeded(Void t) {
            setMessage(MSG_SEARCH_SUCCESS);
            setProgress(3, 0, 3);
        }
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Define Delete Task" >

    private class DeleteTask extends Task<Void, Void> {

        public DeleteTask() {
            super(localApplication);
        }

        @Override
        protected Void doInBackground() throws Exception {
            setMessage(MSG_DELETE_BEGINNING);
            Thread.sleep(150L);
            setProgress(1, 0, 4);
            // Get object is selected to delete
            int selectedIndex = jtbShowTimes.getSelectedRow();
            if (_showTimes == null || selectedIndex == -1) {
                throw new Exception(ERR_DELETE_INVALID_PARAMS);
            }
            Suatchieu cachedShowTime = _showTimes.get(selectedIndex);
            String msg = String.format(MSG_DELETE_CONFIRM, cachedShowTime.getCodeSuatChieu());
            int returnOptionDialog = JOptionPane.showConfirmDialog(localApplication.getMainFrame(), msg, MSG_DELETE_TITLE, JOptionPane.OK_CANCEL_OPTION);
            if (returnOptionDialog == JOptionPane.CANCEL_OPTION) {
                return null;
            }
            setMessage(MSG_DELETE_DATABASE);
            Thread.sleep(150L);
            setProgress(2, 0, 4);
            // Delete database
            SuatChieuDAO.deleteSuatChieus(cachedShowTime);
            // Loading GUI
            setMessage(MSG_LOADING);
            Thread.sleep(150L);
            setProgress(3, 0, 4);
            loadShowTimes();
            Thread.sleep(150L);
            return null;
        }

        @Override
        protected void cancelled() {
            setMessage(ERR_DELETE_TASK);
        }

        @Override
        protected void failed(Throwable thrwbl) {
            setMessage(thrwbl.getMessage());
        }

        @Override
        protected void succeeded(Void t) {
            clearAllTextField();
            defaultButtonState();
            setMessage(MSG_DELETE_SUCCESS);
            setProgress(4, 0, 4);
        }
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Define Update Task" >

    private class UpdateTask extends Task<Void, Void> {

        public UpdateTask() {
            super(localApplication);
        }

        @Override
        protected Void doInBackground() throws Exception {
            setMessage(MSG_UPDATE_BEGINNING);
            Thread.sleep(150L);
            setProgress(1, 0, 4);
            // Get information and prepare object
            int selectedIndex = jtbShowTimes.getSelectedRow();
            if (_showTimes == null || selectedIndex == -1) {
                throw new Exception(ERR_UPDATE_INVALID_PARAMS);
            }
            Suatchieu cachedShowTime = _showTimes.get(selectedIndex);

            String codeShowTime = jtfCodeShowTime.getText();
            String startShowTime = jtfStartTimeShowTime.getText();
            String endShowTime = jtfEndTimeShowTime.getText();


            cachedShowTime.setCodeSuatChieu(codeShowTime);
            cachedShowTime.setGioBatDau(startShowTime);
            cachedShowTime.setGioKetThuc(endShowTime);

            setMessage(MSG_UPDATE_DATABASE);
            Thread.sleep(150L);
            setProgress(2, 0, 4);
            // Update to database
            SuatChieuDAO.updateSuatChieus(cachedShowTime);
            // Loading gui
            setMessage(MSG_LOADING);
            Thread.sleep(150L);
            setProgress(3, 0, 4);
            loadShowTimes();
            Thread.sleep(150L);
            return null;
        }

        @Override
        protected void cancelled() {
            setMessage(ERR_UPDATE_TASK);
        }

        @Override
        protected void failed(Throwable thrwbl) {
            setMessage(thrwbl.getMessage());
        }

        @Override
        protected void succeeded(Void t) {
            clearAllTextField();
            defaultButtonState();
            setMessage(MSG_UPDATE_SUCCESS);
            setProgress(4, 0, 4);
        }
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Define Save Task" >

    private class SaveTask extends Task<Void, Void> {

        public SaveTask() {
            super(localApplication);
        }

        @Override
        protected Void doInBackground() throws Exception {
            setMessage(MSG_SAVE_BEGINNING);
            Thread.sleep(150L);
            setProgress(1, 0, 4);
            // Get all information from fields
            String codeShowTime = jtfCodeShowTime.getText();
            String startShowTime = jtfStartTimeShowTime.getText();
            String endShowTime = jtfEndTimeShowTime.getText();

            // Prepare object
            Suatchieu showTime = new Suatchieu(codeShowTime, startShowTime, endShowTime,
                    ClassUtils.StateFields.DEFAULT_STATUS, null);
            setMessage(MSG_SAVE_DATABASE);
            Thread.sleep(150L);
            setProgress(2, 0, 4);
            // Save into database
            SuatChieuDAO.insertSuatChieus(showTime);
            setMessage(MSG_LOADING);
            Thread.sleep(150L);
            setProgress(3, 0, 4);
            loadShowTimes();
            Thread.sleep(150L);
            return null;
        }

        @Override
        protected void cancelled() {
            setMessage(ERR_SAVE_TASK);
        }

        @Override
        protected void failed(Throwable thrwbl) {
            setMessage(thrwbl.getMessage());
        }

        @Override
        protected void succeeded(Void t) {
            setMessage(MSG_SAVE_SUCCESS);
            setProgress(4, 0, 4);
            clearAllTextField();
            defaultButtonState();
        }
    }
    // </editor-fold>

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnOptionGroups = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jtfSearch = new javax.swing.JTextField();
        jbtnSearch = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtbShowTimes = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jtfCodeShowTime = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jtfStartTimeShowTime = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jtfEndTimeShowTime = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jbtnReset = new javax.swing.JButton();
        jbtnAdd = new javax.swing.JButton();
        jbtnUpdate = new javax.swing.JButton();
        jbtnDelete = new javax.swing.JButton();
        jbtnCancel = new javax.swing.JButton();

        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("GUI/Admin/resources/AdminShowTimes"); // NOI18N
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("jpSearchForm.title"))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        jtfSearch.setText(bundle.getString("jtfSearchShowTimes.title")); // NOI18N
        jtfSearch.setName("jtfSearch"); // NOI18N

        jbtnSearch.setText(bundle.getString("jbtnSearch.title")); // NOI18N
        jbtnSearch.setName("jbtnSearch"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(87, 87, 87)
                .addComponent(jtfSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 304, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 126, Short.MAX_VALUE)
                .addComponent(jbtnSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(79, 79, 79))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtnSearch))
                .addContainerGap(25, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("jpListShowTimes.title"))); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jtbShowTimes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Nums", "Code", "Start time", "End time"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jtbShowTimes.setName("jtbShowTimes"); // NOI18N
        jtbShowTimes.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(jtbShowTimes);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 716, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("jpShowTimesDetailForm.title"))); // NOI18N
        jPanel3.setName("jPanel3"); // NOI18N

        jLabel1.setText(bundle.getString("jlbCodeShowTimes.title")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jtfCodeShowTime.setName("jtfCodeShowTime"); // NOI18N

        jLabel2.setText(bundle.getString("jlbStartShowTimes.title")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jtfStartTimeShowTime.setName("jtfStartTimeShowTime"); // NOI18N

        jLabel3.setText(bundle.getString("jlbEndShowTimes.title")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jtfEndTimeShowTime.setName("jtfEndTimeShowTime"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(163, 163, 163)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 80, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtfCodeShowTime, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtfStartTimeShowTime, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtfEndTimeShowTime, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(208, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtfCodeShowTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtfStartTimeShowTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jtfEndTimeShowTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("jpAction.title"))); // NOI18N
        jPanel4.setName("jPanel4"); // NOI18N

        java.util.ResourceBundle bundle1 = java.util.ResourceBundle.getBundle("GUI/Admin/resources/AdminRoom"); // NOI18N
        jbtnReset.setText(bundle1.getString("jbtnReset.title")); // NOI18N
        jbtnReset.setName("jbtnReset"); // NOI18N

        jbtnAdd.setText(bundle1.getString("jbtnAddRoom.title")); // NOI18N
        jbtnAdd.setName("jbtnAdd"); // NOI18N

        jbtnUpdate.setText(bundle1.getString("jbtnUpdateRoom.title")); // NOI18N
        jbtnUpdate.setName("jbtnUpdate"); // NOI18N

        jbtnDelete.setText(bundle1.getString("jbtnDeleteRoom.title")); // NOI18N
        jbtnDelete.setName("jbtnDelete"); // NOI18N

        jbtnCancel.setText(bundle1.getString("jbtnCancel.title")); // NOI18N
        jbtnCancel.setName("jbtnCancel"); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(90, 90, 90)
                .addComponent(jbtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32)
                .addComponent(jbtnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(28, 28, 28)
                .addComponent(jbtnUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(30, 30, 30)
                .addComponent(jbtnDelete, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32)
                .addComponent(jbtnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(99, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtnReset)
                    .addComponent(jbtnAdd)
                    .addComponent(jbtnUpdate)
                    .addComponent(jbtnDelete)
                    .addComponent(jbtnCancel))
                .addContainerGap(12, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup btnOptionGroups;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbtnAdd;
    private javax.swing.JButton jbtnCancel;
    private javax.swing.JButton jbtnDelete;
    private javax.swing.JButton jbtnReset;
    private javax.swing.JButton jbtnSearch;
    private javax.swing.JButton jbtnUpdate;
    private javax.swing.JTable jtbShowTimes;
    private javax.swing.JTextField jtfCodeShowTime;
    private javax.swing.JTextField jtfEndTimeShowTime;
    private javax.swing.JTextField jtfSearch;
    private javax.swing.JTextField jtfStartTimeShowTime;
    // End of variables declaration//GEN-END:variables
}
